ifndef prefix
	prefix=.
endif

include=include
lib=lib
# 直接再赋值给prefix不行，install 时还是用的 原来的prefix
prefix1=$(prefix)/
prefix2=$(subst //,/,$(prefix1))

all:debug release 

debug:
	$(MAKE) -C threadpool debug
	$(MAKE) -C log debug
	$(MAKE) -C net debug

release:
	$(MAKE) -C threadpool release
	$(MAKE) -C log release
	$(MAKE) -C net release

clean:
	$(MAKE) -C threadpool clean
	$(MAKE) -C log clean
	$(MAKE) -C net clean

install:
	@echo install to $(prefix2)
	@if [[ ! -d $(prefix2) ]]; then \
		mkdir -p $(prefix2) ;\
	fi
	@if [[ ! -d $(prefix2)$(lib) ]]; then \
		mkdir -p $(prefix2)$(lib) ;\
	fi
	
	@if [[ ! -d $(prefix2)$(include)/threadpool ]]; then \
		mkdir -p $(prefix2)$(include)/threadpool ;\
	fi
	cp threadpool/$(include)/*.h $(prefix2)$(include)/threadpool
	cp utils/$(include)/*.h $(prefix2)$(include)/threadpool
	cp threadpool/*.so $(prefix2)$(lib)
	
	@if [[ ! -d $(prefix2)$(include)/net ]]; then \
		mkdir -p $(prefix2)$(include)/net ;\
	fi
	cp net/$(include)/*.h $(prefix2)$(include)/net/
	cp net/*.so $(prefix2)$(lib)
	
	@if [[ ! -d $(prefix2)$(include)/log ]]; then \
		mkdir -p $(prefix2)$(include)/log ;\
	fi
	cp log/$(include)/*.h $(prefix2)$(include)/log/
	cp log/*.so $(prefix2)$(lib)



